import java.util.*;

/**
 * @author LKQ
 * @date 2022/3/28 8:52
 * @description
 */
public class Solution2 {
    public static void main(String[] args) {
        Solution2 solution2 = new Solution2();
        char[] letters = {'a', 'b'};
        solution2.nextGreatestLetter(letters, 'z');
    }

    public char nextGreatestLetter(char[] letters, char target) {
        int lo = 0, hi = letters.length;
        while (lo < hi) {
            int mid = lo + (hi -lo) / 2;
            if (letters[mid] <= target) {
                lo = mid + 1;
            }else {
                hi = mid;
            }
        }
        return letters[lo % letters.length];
    }
}
